<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <h:outputStylesheet library="css" name="mainstyle.css"/>
        <title>System</title>

        <h:outputScript library="javascript" name="jquery.price_format.1.3.js"/>
        
        
          <script type="text/javascript">

                function apply_price_format(class_name) {
                    //jQuery.noConflict();
                  
                    jQuery(function($){ $(class_name).priceFormat({ prefix: 'R$ ', centsLimit: 2, centsSeparator: ',', thousandsSeparator: '.' }); });
                }

                  function apply_quant_format(class_name) {
                    //jQuery.noConflict();

                    jQuery(function($){ $(class_name).priceFormat({ centsSeparator: '.', thousandsSeparator: '.' }); });
                }
              
          </script>

    </h:head>

    <h:body>
         <p:growl id="growl" />
        <ui:insert name="dialogs">

        </ui:insert>

       <p:layout fullPage="true">
           <p:layoutUnit position="north" size="80" >
                     <div align="right" style="float: right; margin-right: 20px; width: 33%" >

                                    <h:form id="left_form" >
                                        <h:panelGrid columns="2">
                                            <h:outputText value="Usuário:" style="font-weight: bold;"/>
                                            <h:outputText value="#{dataSessionManagedBean.currentUser.name}" />

                                            <h:outputText value="Obra:" style="font-weight: bold;"/>
                                            <h:panelGroup id="currentUserClinicListGroup">
                                                <h:selectOneMenu value="#{dataSessionManagedBean.currentObra}"
                                                                 style="width: 250px"
                                                                 converter="obraConverter">
                                                    <f:selectItem itemLabel="Selecione uma Obra" itemValue="#{null}"/>
                                                    <f:selectItems value="#{dataSessionManagedBean.currentUser.obras}"
                                                                   var="obra" itemLabel="#{obra.name}"
                                                                   itemValue="#{obra}"/>
                                                    <p:ajax update="@this" />
                                                </h:selectOneMenu>
                                            </h:panelGroup>
                                        </h:panelGrid>
                                        <p:commandLink value="Logout" action="#{dataSessionManagedBean.logout}"
                                                       style="color: darkred; font-weight: bold;" ajax="false" />
                                    </h:form>
                     </div>

           </p:layoutUnit>



        <p:layoutUnit position="west" size="210" header="Menu" resizable="true" closable="true" collapsible="true">
            <h:form id="formMenuTemplate" >
             <p:accordionPanel>

                <p:tab title="Cadastros" id="tabCadastros">

                   <p:commandButton value="Banco"           action="#{mainMenuBean.bankPage()}"          style=" width: 140px;  " ajax="false" />
                   <p:commandButton value="Cargo"           action="#{mainMenuBean.cargoPage()}"         style=" width: 140px;  " ajax="false"        />
                   <p:commandButton value="Centro de custo" action="#{mainMenuBean.centroCustoPage()}"   style=" width: 140px;  " ajax="false" />
                   <p:commandButton value="Cliente"         action="#{mainMenuBean.clientePage()}"       style="width: 140px"     ajax="false" />
                   <p:commandButton value="Cidade"          action="#{mainMenuBean.cidadePage()}"        style="width: 140px"     ajax="false" />
                   <p:commandButton value="Empresa"         action="#{mainMenuBean.empresaPage()}"       style="width: 140px"     ajax="false" />
                   <p:commandButton value="Produto"         action="#{mainMenuBean.produtoPage()}"       style=" width: 140px; "  ajax="false" />
                   <p:commandButton value="Fornecedor"      action="#{mainMenuBean.fornecedorPage()}"    style="width: 140px "    ajax="false" />
                   <p:commandButton value="Obra"            action="#{mainMenuBean.obraPage()}"          style="width: 140px"     ajax="false" />
                   <p:commandButton value="Funcionario"     style="width: 140px"     ajax="false" />
                   <p:commandButton value="Detalhe"         action="#{mainMenuBean.detalhe_produto()}"   style="width: 140px"     ajax="false" />
                   <p:commandButton value="Marca"           action="#{mainMenuBean.marca_produtoPage()}" style="width: 140px"     ajax="false" />
              
                </p:tab>
                <p:tab title="Compras" id="tabCompras" rendered="#{sharedPermissionManagedBean.hasPermission('VIEW_COMPRAS_TAB')}">
                    <p:commandButton value="Pedido" action="#{mainMenuBean.pedidoPage()}" style="width: 140px" ajax="false" />
                        <p:commandButton value="Nota Fiscal" action="#{mainMenuBean.notaFiscalLance()}" style="width: 140px" ajax="false" />
                </p:tab>

                <p:tab title="Financeiro" id="tabFinanceiro" rendered="#{sharedPermissionManagedBean.hasPermission('VIEW_FINANCEIRO_TAB')}">
                     <p:commandButton value="Contas a pagar" action="#{mainMenuBean.contasPagarPage}" style="width: 140px" ajax="false" />
                </p:tab>

                <p:tab title="Gerencial" id="tabGerencial" rendered="#{sharedPermissionManagedBean.hasPermission('VIEW_GERENCIAL_TAB')}">
                    <p:commandButton value="Gastos" action="#{mainMenuBean.gastosPage()}" style="width: 140px" ajax="false" />
                </p:tab>


                <p:tab title="Sistema" id="tabSistema" rendered="#{sharedPermissionManagedBean.hasPermission('VIEW_SYSTEM_TAB')}">
                    <h:panelGrid columns="2" cellpadding="10">
                        <p:commandButton value="Usuários" action="#{mainMenuBean.userPage()}" style="width: 140px" ajax="false" />
                    </h:panelGrid>
                </p:tab>


             </p:accordionPanel>


           </h:form>
        </p:layoutUnit>


    <p:layoutUnit position="center">
           <h:panelGroup id="main_content_panel">
                      <ui:insert name="content">Conteúdo</ui:insert>
           </h:panelGroup>
    </p:layoutUnit>

</p:layout>


    </h:body>

</html>